﻿import { useAccess, Access } from 'umi';

export default [
    {
        path: '/user',
        layout: false,
        routes: [
            { path: '/user/login', layout: false, name: '登录', component: './user/login' },
            { path: '/user', redirect: '/user/login' },
            //{ component: '404', path: '/*' },
        ],
    },
    {
        path: '/dashboard',
        name: 'Dashboard',
        icon: 'dashboard',
        access: 'hasDashboard',
        routes: [
            {
                name: '统计页',
                icon: 'smile',
                path: '/dashboard/statistics',
                component: './dashboard/statistics',
            },
        ],
    },
    {
        path: '/organization',
        icon: 'SolutionOutlined',
        name: '组织管理',
        access: 'hasOrganization',
        routes: [
            {
                name: '组织列表',
                icon: 'smile',
                path: '/organization/org-list',
                component: './organization/org-list',
                access: 'hasOrganizationOrg',
            },
            {
                name: '租户资源管理',
                icon: 'smile',
                path: '/organization/resource-manager/:id',
                component: './organization/resource-manager',
                hideInMenu: true
            },
            {
                name: '用户列表',
                icon: 'smile',
                path: '/organization/user-list',
                component: './organization/user-list',
                access: 'hasOrganizationUser',
            },
        ],
    },
    {
        path: '/power',
        icon: 'HeatMapOutlined',
        name: '算力中心',
        access: 'hasPower',
        routes: [
            {
                name: '资源池',
                icon: 'smile',
                path: '/power/data-center-list',
                component: './power/data-center-list',
                access: 'hasPowerSystemResourceManager',
            },
            {
                name: '规格管理',
                icon: 'smile',
                path: '/power/sku-list',
                component: './power/sku/sku-list',
                access: 'hasPowerSystemResourceManager',
            },
            {
                name: '规格创建',
                icon: 'smile',
                path: '/power/sku-add',
                component: './power/sku/sku-add',
                hideInMenu: true,
            },
            {
                name: '规格编辑',
                icon: 'smile',
                path: '/power/sku-edit/:id',
                component: './power/sku/sku-edit',
                hideInMenu: true,
            },
            {
                name: '主机管理',
                icon: 'smile',
                path: '/power/host-computer/list',
                component: './power/host-computer/list',
                access: 'hasPowerSystemResourceManager',
            },
            {
                name: '主机创建',
                icon: 'smile',
                path: '/power/host-computer/add',
                component: './power/host-computer/add',
                hideInMenu: true,
            },
            {
                name: '主机编辑',
                icon: 'smile',
                path: '/power/host-computer/edit/:id',
                component: './power/host-computer/edit',
                hideInMenu: true,
            },
            {
                name: '存储管理',
                icon: 'smile',
                path: '/power/storage',
                component: './power/storage',
                access: 'hasPowerSystemResourceManager',
            },
            {
                name: '网络管理',
                icon: 'smile',
                path: '/power/network',
                component: './power/network',
                access: 'hasPowerSystemResourceManager',
            },
            {
                name: '开通算力',
                icon: 'smile',
                path: '/power/resource-activate/:id',
                component: './power/resource-activate',
                hideInMenu: true
            },
            // 以下为租户菜单
            {
                name: '主机列表',
                icon: 'smile',
                path: '/power/custom-host-computer/list',
                component: './power/custom-host-computer/list',
                access: 'hasPowerCustomResourceManager',
            },
            {
                name: '存储列表',
                icon: 'smile',
                path: '/power/custom-storage',
                component: './power/custom-storage',
                access: 'hasPowerCustomResourceManager',
            },
            {
                name: '网络列表',
                icon: 'smile',
                path: '/power/custom-network',
                component: './power/custom-network',
                access: 'hasPowerCustomResourceManager',
            },
        ],
    },
    {
        path: '/order',
        icon: 'MoneyCollectOutlined',
        name: '结算中心',
        routes: [
            {
                name: '订单管理',
                icon: 'smile',
                path: '/order/list',
                component: './order/list'
            },
            { name: '账单明细', icon: 'smile', path: '/order/billing/list', component: './order/billing/list' },
        ],
        access: 'hasOrder',
    },
    {
        name: '系统设置',
        icon: 'SettingOutlined',
        path: '/system',
        routes: [
            { name: '操作日志', icon: 'smile', path: '/system/operate-log', component: './system/operate-log' },
        ],
        access: 'hasSystemConfig',
    },
    {
        name: 'LICENSE管理',
        icon: 'KeyOutlined',
        path: '/license/manager',
        component: './license/manager',
        access: 'hasLicense',
    },
    {
        name: '个人页',
        icon: 'user',
        path: '/account',
        routes: [
            {
                name: '个人设置',
                icon: 'smile',
                path: '/account/settings',
                component: './account/settings',
            },
        ],
    },
    //大屏 
    { name: '大屏',
        path: '/bigScreen',
        component: './bigScreen/index',
        // redirect: '/dashboard/statistics',
    },
    // {
    //     name: 'LICENSE',
    //     icon: 'MoneyCollectOutlined',
    //     path: '/license/custom',
    //     component: './license/custom',
    //     access: 'isSystem',
    // },
    {
        path: '/',
        // redirect: '/dashboard/statistics',
        redirect: (to) => {
            // 根据用户权限决定重定向路径
            const access = useAccess();
            if (access.isSystem) {
                return '/dashboard/statistics';
            } else {
                return '/power/host-computer/list';
            }
        },
    },
    { component: '404', path: '/*' },

];
